package com.jml.loadbalancer;

import com.jml.loadbalancer.entity.WeightEntity;
import com.jml.loadbalancer.impl.RotationLoadBalancer;
import com.jml.loadbalancer.impl.IpHashLoadBalancer;

import com.jml.loadbalancer.impl.WeightLoadBalancer;
import java.util.ArrayList;
import java.util.List;


public class Test001 {
    public static void main(String[] args) {
        LoadBalancer loadBalancer = new RotationLoadBalancer();
        List<String> addres = new ArrayList<String>();
        addres.add("192.168.212.1:8080");
        addres.add("192.168.212.1:8081");
        loadBalancer.getSingleAddres(addres);
        loadBalancer.getSingleAddres(addres);
        loadBalancer.getSingleAddres(addres);
        loadBalancer.getSingleAddres(addres);
        loadBalancer.getSingleAddres(addres);
        loadBalancer.getSingleAddres(addres);

        // nginx
        List<WeightEntity> weightEntities = new ArrayList<WeightEntity>();
        weightEntities.add(new WeightEntity("192.168.212.1:8080", 1));
        weightEntities.add(new WeightEntity("192.168.212.1:8081", 2));
        LoadBalancer loadBalancer001 = new WeightLoadBalancer(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        loadBalancer001.getSingleAddres(weightEntities);
        
        IpHashLoadBalancer loadBalancer002 = new IpHashLoadBalancer();
        loadBalancer002.getSingleAddres(addres, "192.168.1.1");
        loadBalancer002.getSingleAddres(addres, "192.168.1.2");
        // alibabaCloud

    }
}
